<?php
namespace app\home\model;
use \think\Db;

class ParentingModel
{
    /**
     * 育儿知识分类
     */
    public function parentingType(){
        $parentingList = Db::table('knows_type')->where('is_del', 0)->select();
        return $parentingList;
    }

    /**
     * 育儿知识分类One
     */
    public function parentingTypeOne($id){
        $parentingTypeOne = Db::table('knows_type')->where("id = $id AND is_del = 0")->find();
        return $parentingTypeOne;
    }

    /**
     * 育儿知识分类Two
     */
    public function parentingTypeTwo($id){
        $parentingTypeOne = Db::table('knows_type')->where("id = $id AND is_del = 0")->find();
        return $parentingTypeOne;
    }

    /**
     * 育儿知识最新资讯
     */
    public function parentingInfo(){
        $parentingInfo = Db::table('knows')->order('knows_time desc')->where('is_del', 0)->find();
        return $parentingInfo;
    }

    /**
     * 育儿知识最新资讯Two
     */
    public function parentingInfoTwo(){
        $parentingInfo = Db::table('knows')->order('knows_time desc')->where('is_del', 0)->limit(1,1)->select();
        return $parentingInfo;
    }

    /**
     * 育儿知识最新资讯Three
     */
    public function parentingInfoThree(){
        $parentingInfoThree = Db::table('knows')->order('knows_time desc')->where('is_del', 0)->limit(2,2)->select();
        return $parentingInfoThree;
    }

    /**
     * 育儿知识列表
     */
    public function parentingList(){
        $threeList = Db::table('knows')
            ->join('knows_type','knows.knows_type_id = knows_type.id')
            ->where("knows.is_del = 0 AND knows_type.is_del = 0")
            ->select();
        return $threeList;
    }

    /**
     * 育儿知识详情页
     */
    public function detailsPage($id){
        $detailsPage = Db::table('knows')->where("knows_type_id = $id AND is_del = 0")->order('knows_time desc')->select();
        return $detailsPage;
    }

    /**
     * 育儿知识详情find
     */
    public function detailsInfo($id){
        $detailsInfo = Db::table('knows')->where("id = $id AND is_del = 0")->order('knows_time desc')->find();
        return $detailsInfo;
    }

}